<template>
  <div class="app-container">


    <div class="nav">
      <el-select v-model="value1" placeholder="选择会议室类型" @change="getListByQuery">
        <el-option
          v-for="item in kindList"
          :key="item.kind"
          :label="item.kind"
          :value="item.kind">
        </el-option>
      </el-select>

      <el-select v-model="value2" placeholder="选择会议室最小容量" @change="getListByQuery">
        <el-option
          v-for="item in options2"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </div>

    <br><br>
    <el-table
      :data="list"
      border
      fit
      highlight-current-row
      @row-click="handle">

      <el-table-column prop="name" label="名称" />

      <el-table-column prop="kind" label="类别"/>


      <el-table-column type="String" prop="cover" label="实景照片" sortable >
        <template   slot-scope="scope">
          <img :src="scope.row.cover"  min-width="250" height="250" />
        </template>

      </el-table-column>
      <el-table-column prop="capacity" label="容量"/>
      <el-table-column prop="reserveNumber" label="本学期可预约次数"/>
      <el-table-column prop="describe1" label="备注"/>

      <el-table-column type="status" prop="state" label="状态" sortable >
        <template   slot-scope="scope" >
          <el-tag type="info" v-if="scope.row.state==0">不可用</el-tag>
          <el-tag type="success" v-else>可用</el-tag>
        </template>

      </el-table-column>

            <el-table-column label="操作" width="200" align="center">
              <template slot-scope="scope">
                  <el-button type="primary" size="mini" icon="el-icon-edit" @click.native.stop="update(scope.row.id)">修改</el-button>
                <el-button type="danger" size="mini" icon="el-icon-delete" @click.native.stop="deleteById(scope.row.id)">删除</el-button>
              </template>
            </el-table-column>
    </el-table>
  </div>
</template>
<script>
import room from "../../api/room"
import kind from "../../api/kind";
export default{
  data(){
    return{
      list:null,//查询后的接口集合
      value1:null,
      value2:null,
      kindList:null,
      options2: [
        {
          value: 'null',
          label: '无'
        },{
        value: '80',
        label: '80'
      }, {
        value: '100',
        label: '100'
      }, {
        value: '150',
        label: '150'
      },
        {
          value: '200',
          label: '200'
        },
      ],
    }
  },
  created(){
    this.listAll()
    this.listKind()
  },
  methods:{

    listAll(){
      room.list()
        .then(response=>{
          this.list=response.data.list
        })
    },
    listKind() {
      kind.list()
        .then(response=>{
          this.kindList = response.data.list
        })
    },

    getListByQuery(){
      room.getQuery(this.value1,this.value2)
        .then(response=>{
          this.list=response.data.list
        })
    },

    handle(row, event, column){
      this.$router.push({ path: '/room_time_slice/room_time_slice/'+row.id })
    },
    deleteById(id){
      room.deleteById(id)
        .then(response=>{
          this.$message({
            message: '删除成功',
            type: 'success'
          });
          this.listAll()
        })
    },
    update(id){
      this.$router.push({ path: '/room_update/room_update/'+id })
    }
  }
}
</script>
<style>

</style>
